<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>配餐配货管理-配餐管理-新增配货</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/apply_assets/assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/apply_assets/assets/css/style.css" rel="stylesheet">
	<link href="/apply_assets/assets/css/font-awesome.css" rel="stylesheet">
  <link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" /> 
</head>
<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 配餐/配货管理</span><b class="fa fa-caret-right"></b><i><a href="../配餐配货管理-配货管理.html">配货管理</a></i><b class="fa fa-caret-right"></b><i>新增配货</i></div>
			</div>
      <div class="seltemple">
      <form class="form-inline">
        <div class="col-xs-12">
           <div class="col-xs-3 mes-btn newpei-add"><button type="button" onclick="addh()">添加</button></div>  
          <div class="col-xs-3 mes-btn off-btn"><button type="button" id="save" >保存</button><button>取消</button></div>
        </div>
      </div>

      <div class="personset-content col-xs-12" id="appl">   
        </div>
        </form>          
		</div>	
    </div>
    <script type="text/javascript" src="/apply_assets/assets/js/jquery.min.js"></script>
     <script type="text/javascript" src="/apply_assets/assets/js/personset-jq.js"></script>     
     <script src="/plugins/SweetAlert/sweetalert.min.js"></script><!--alert插件-->
      <script src="/js/jquery.form.js"></script><!--form表单插件-->
      <script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
     <script type="text/javascript">
      var apply = '<div class="col-xs-4 sels-content" id="del<?=$Datas['com_id']?>"><form><label>名称</label><input type="text" style="width: 200px" name="applyname[]"><label>数量</label><input type="text" placeholder="填写数量" name="applynum[]"><label>单位</label><select name="applycom[]"><?foreach($tCMDatas as $key => $Datas){?><option value="<?=$Datas['com_name']?>"><?=$Datas['com_name']?></option><?}?></select></form><img src="/apply_assets/assets/img/del_03.png" onclick="del($(this).parent().remove())"></div>' 
      $('#appl').append(apply);
     function addh(){
      var apply = '<div class="col-xs-4 sels-content" id="del<?=$Datas['com_id']?>"><form><label>名称</label><input type="text" style="width: 200px" name="applyname[]"><label>数量</label><input type="text" placeholder="填写数量" name="applynum[]"><label>单位</label><select name="applycom[]"><?foreach($tCMDatas as $key => $Datas){?><option value="<?=$Datas['com_name']?>"><?=$Datas['com_name']?></option><?}?></select></form><img src="/apply_assets/assets/img/del_03.png" onclick="del($(this).parent().remove())"></div>' 
      $('#appl').append(apply);
     }
     function del(){

     }
    $('#save').click(function(){
        var data = $('form').serialize();
        $.post('/admin_apply/addlist',data,function(obj){
            cg_alert_add(obj,'/admin_apply/list','/admin_apply/');
        });
    });
    function cg_alert_add(obj,list_url,add_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续添加',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = add_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_alert_edit(obj,list_url,edit_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续修改',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = edit_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_confirm_del(del_url,jump_url){
    swal({
            title: '您确定要删除吗？',
            text:'删除之后不能恢复',
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText:'确定',
            closeOnConfirm: false,
            cancelButtonText:'取消'
        },
        function(isConfirm){
            if(isConfirm){
                window.obj = '';
                $.ajax({
                    url: del_url,
                    dataType: "json",
                    async:false,
                    success: function (obj) {
                        window.obj = obj;
                    }
                });

                if(window.obj.status == 1){
                    swal({title:"删除成功!", type:"success"},function(){
                        location.href = jump_url;
                    });
                }else{
                    swal({title:window.obj.msg, type:"error"});
                }
            }
        });
}
     </script>
    
</body>
</html>
